<?php
/**
 * Latest forum posts
 *
 * @uses $vars['entity']
 */
if ($vars ['entity']->forum_enable == 'no') {
	return true;
}

$group = $vars ['entity'];

// / review

// only add review with grouptype != SUBJECT_GROUP
if ($group->grouptype != SUBJECT_GROUP) {

	// review
	$all_link = elgg_view ( 'output/url', array (
			'href' => "review/owner/$group->guid",
			'text' => elgg_echo ( 'Xem tất cả' ),
			'is_trusted' => true
	) );

	elgg_push_context ( 'widgets' );
	$options = array (
			'type' => 'object',
			'subtype' => 'mark',
			'container_guid' => $group->getGUID (),
			'full_view' => false
	);
	$content = elgg_list_entities_from_metadata ( $options );
	elgg_pop_context ();

	if (strlen ( $content ) < 70) {
		$content = '<p>' . elgg_echo ( 'Hiện chưa có đánh giá nào từ giảng viên' ) . '</p>';
	}


	echo elgg_view ( 'groups/profile/module', array (
			'title' => elgg_echo ( 'Đánh giá của giảng viên' ),
			'content' => $content,
			'all_link' => $all_link,
			'add_link' => $new_review_link
	) );
	///////////////////////////////////////////////////////////////////////////
	// --------------------------- svn item ---------------------------------//
	$all_link = elgg_view ( 'output/url', array (
			'href' => "groups/svn/$group->guid",
			'text' => elgg_echo ( 'Xem tất cả' ),
			'is_trusted' => true
	) );

	elgg_push_context ( 'widgets' );

	$metadata_commit_options = array (
			array (
					'name' => 'is_svn_commit',
					'value' => true
			)
	);

	$options = array (
			'type' => 'object',
			'subtype' => 'groupforumtopic',
			'container_guid' => $group->getGUID (),
			'limit' => 3,
			'full_view' => false,
			'pagination' => false,
			'metadata_name_value_pairs' => $metadata_commit_options
	);


	$content = elgg_list_entities_from_metadata ( $options );

	elgg_pop_context ();

	if (strlen ( $content ) < 70) {
		$content = '<p>' . elgg_echo ( 'Hiện chưa có thông tin về hoạt động SVN' ) . '</p>';
	}

	echo elgg_view ( 'groups/profile/module', array (
			'title' => elgg_echo ( 'Hoạt động SVN' ),
			'content' => $content,
			'all_link' => $all_link,
			'add_link' => $new_review_link
	) );
}


$all_link = elgg_view ( 'output/url', array (
		'href' => "discussion/owner/$group->guid",
		'text' => elgg_echo ( 'link:view:all' ),
		'is_trusted' => true 
) );

elgg_push_context ( 'widgets' );

$metadata_options = array (
		array (
				'name' => 'is_svn_update',
				'value' => false 
		) 
);
$options = array (
		'type' => 'object',
		'subtype' => 'groupforumtopic',
		'container_guid' => $group->getGUID (),
		'limit' => 6,
		'full_view' => false,
		'pagination' => false,
		'metadata_name_value_pairs' => $metadata_options 
);
$content = elgg_list_entities_from_metadata ( $options );
elgg_pop_context ();

if (! $content) {
	$content = '<p>' . elgg_echo ( 'discussion:none' ) . '</p>';
}

$new_link = elgg_view ( 'output/url', array (
		'href' => "discussion/add/" . $group->getGUID (),
		'text' => elgg_echo ( 'groups:addtopic' ),
		'is_trusted' => true 
) );

echo elgg_view ( 'groups/profile/module', array (
		'title' => elgg_echo ( 'discussion:group' ),
		'content' => $content,
		'all_link' => $all_link,
		'add_link' => $new_link 
) );


// retry svn item
